<?php session_start();
include("authentication.php");
require_once('../includes/conn.php'); 
require_once('../includes/settings.inc.php');
include("../includes/functions_emagineit.php");
$obj = new EmagineIT();

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if($_POST["publish"]) $publish = 1;
else $publish = 0;

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) 
{
	
	if(isset($_POST['new_page']) && $_POST['new_page'] =="Add New Page")
	{
		
					
			 
				$SQL = "insert into categories set cat_name = '".$_REQUEST['cat_name']."', cat_desc = '".$_REQUEST['cat_desc']."', cat_status = '1'";
		
	}
	else
	{
	
	 		
	
	$SQL = "update categories set cat_name = '".$_REQUEST['cat_name']."', cat_desc = '".$_REQUEST['cat_desc']."', cat_status = '1' where cat_id = '".$_REQUEST["code"]."'";
			
		
	}
	 $Result1 = mysql_query($SQL) or die($SQL);
	  if(!$Result1)
	   $msg = "Error: ".mysql_error()." - ".mysql_errno();
	  else
	  { 
		  $insertGoTo = "contents.php";
		  if (isset($_SERVER['QUERY_STRING'])) {
			$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
			$insertGoTo .= $_SERVER['QUERY_STRING'];
		  }
	  echo "<script language='javascript'>
			alert('Page saved successfully!');
			window.location = 'container.php?vu=viewcategories&for=category';
			</script>";  	
		//header(sprintf("Location: %s", $insertGoTo));
	  }//END ELSE
}

		$s1 = "select * from categories where cat_id = '".$_REQUEST["code"]."'";
		
		$q1 = mysql_query($s1) or die($s1);
		$row_sel = mysql_fetch_array($q1); 
		
		
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$site_name?> - Admin Panel</title>
<META NAME="ROBOTS" CONTENT="NOARCHIVE">
<META NAME="ROBOTS" CONTENT="NOINDEX">
<META NAME="ROBOTS" CONTENT="NOIMAGEINDEX">
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	// <![CDATA[
	var myMenu;
	window.onload = function() {
		myMenu = new SDMenu("my_menu");
		myMenu.init();
	};
	// ]]>
	function change_status(type)
	{
		if(type == '1')
		{
			document.getElementById("email_details").style.display = 'inline';
		}
		else
		if(type == '0')
		{
			document.getElementById("email_details").style.display = 'none';
		}
	}
</script>
<script type="text/javascript" src="sdmenu/sdmenu.js"></script>
<script language="javascript" type="text/javascript" src="../include/validate.js"></script>
<script language="javascript" type="text/javascript" src="calender/calendarcontrol.js"></script>
<link href="calender/CalendarControl.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?=$path?>js/jsapi.js"></script>
<link href="css/styleer.css" rel="stylesheet" type="text/css">
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" />
<link href="<?=$path?>css/styler.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<?=$path?>js/globale_jsfile.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
function change_language(typ)
{
	if(typ == 'show_en')
	{
		document.getElementById("show_fr").style.display = "none";
		document.getElementById("show_ar").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_en').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'en';
	}
	else
	if(typ == 'show_fr')
	{
		document.getElementById("show_fr").style.display = "none";
		document.getElementById("show_ar").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_fr').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'fr';
	}
	else
	if(typ == 'show_ar')
	{
		document.getElementById("show_fr").style.display = "none";
		document.getElementById("show_ar").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_ar').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'ar';
	}
}
</script>
</head>
<body >
<table width="987" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
    <td width="987"><img src="<?=$path?>images/spacer.gif" width="100" height="25" /></td>
  </tr>
  
  <tr>
    <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
	
	<tr>
        <td><img src="<?=$path?>images/index_03.gif" width="46" height="57" alt="" /></td>
        <td><img src="<?=$path?>images/index_04.gif" width="895" height="57" alt="" /></td>
        <td><img src="<?=$path?>images/index_05.gif" width="46" height="57" alt="" /></td>
      </tr>
	
	
	<tr>
        <td background="<?=$path?>images/index_07.gif"><img src="<?=$path?>images/spacer.gif" width="46" height="100" /></td>
	
          <td valign="top" bgcolor="#FFFFFF">
		
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
         
		 
		  <tr>
            <td>&nbsp;</td>
          </tr>    
		  
		  
		  
		  <tr>
			        <td valign="top">
				
				<table width="100%"  border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="16%" valign="top">
					
					<table width="80%"  border="0" cellpadding="0" cellspacing="0">
					
					
					
					
					 <tr>
                    <td><table width="80%"  border="0" cellspacing="0" cellpadding="0">
                      
                      <tr>
                        <td valign="top"><?php include("leftnavigation.php");?></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td height="6"><img src="images/spacer.gif" width="1" height="1"></td>
                  </tr>
                  
                  
                </table></td>
                <td width="84%" valign="top">
				
				<table width="99%"  border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="233" valign="top" class="blueBarborder2"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
						
                      <tr>
                        <td height="31" class="blueBarborder"><table width="97%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td class="blackTxt"><?=$site_name?> - Admin Panel </td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="202" valign="top" bgcolor="#dbedf1"><table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="8"><img src="images/spacer.gif" width="1" height="1"></td>
                          </tr>
                          <tr>
                            <td>
<?php
if(isset($include_page) && $include_page !=NULL)
 include($include_page);
else
{ 
?>							
			<form name="RTEDemo" action="<?php echo $editFormAction; ?>" method="post" onSubmit="return submitForm();" enctype="multipart/form-data">
                              <table width="100%" align="left" cellpadding="0" cellspacing="0">
                                <tr valign="baseline">
                                  <td colspan="3" align="center" nowrap class="Redsmalltext">
								  <strong><?php echo $msg?></strong></td></tr>
								 
								  
								 
								  <tr><td colspan="3" valign="top"><div id="show_en"><table width="100%" border="0" cellspacing="0" cellpadding="0">
								  
								   <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								 								  
								  <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr> 
								 
								 
													
																  
								  
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>Category : </strong></td>
                                  <td colspan="2">
<input type="text" name="cat_name" value="<?php echo $_POST['cat_name']?$_POST['cat_title']:$row_sel['cat_name'];?>" size="45">                                  </td>
                                </tr>
								
								 <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr> 
								 
								 <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="141" valign="top" align="left" nowrap class="smalltext"><strong>Description : </strong></td>
                                  <td colspan="2">
								  <textarea name="cat_desc" id="cat_desc" cols="35" rows="15"><?php echo $_POST['cat_desc']?$_POST['cat_desc']:$row_sel['cat_desc'];?></textarea>
								                                    </td>
                                </tr>
                               
								
																  
															
								   
									
                                <tr valign="baseline">
                                  <td nowrap align="right">&nbsp;</td>
                                  <td colspan="2">
								  <input name="submit" type="submit" value="Save Page">
								  <input name="language" type="hidden" id="language" value="en">
             					  <input name="code" type="hidden" id="code" value="<?php echo $_REQUEST['code']?>" />
								  <input name="for" type="hidden" id="for" value="<?php echo $_REQUEST['for']?>" />
              					  <input name="new_page" type="hidden" id="code" value="<?php echo $_REQUEST['vu']?>" />			  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                              </table>
                              <input type="hidden" name="MM_insert" value="form1">
                            </form>
							<?php
							}
							?>							</td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
			  </table>
			  </td>
			  </tr>
			  </table>
			  </td>
			  
			  
			  
			<td background="<?=$path?>images/index_21.gif"><img src="<?=$path?>images/spacer.gif" width="46" height="100" /></td>
      </tr>
      <tr>
        <td><img src="<?=$path?>images/index_37.gif" width="46" height="48" alt="" /></td>
        <td background="<?=$path?>images/index-over_38.gif">&nbsp;</td>
        <td><img src="<?=$path?>images/index_40.gif" width="47" height="48" alt="" /></td>
      </tr>
    </table></td>
  </tr>
			  

 <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</body>
</html>
